import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseConnection {
	private static Connection connection;

	private DatabaseConnection() {
		// Private constructor to prevent instantiation
	}

	public static Connection getConnection() {
		if (connection == null) {
			try {
				// Establish the connection
				connection = DriverManager.getConnection(
						ReadOnlyData.url,ReadOnlyData.sqlUserName,ReadOnlyData.password);

			} catch (Exception e) {
				e.printStackTrace(); // Handle exceptions appropriately
			}
		}
		return connection;
	}

	public static void closeConnection() {
		if (connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace(); // Handle exceptions appropriately
			}
		}
	}
}
